while True:
    choose1 =input('请输入以下选项中您想要进行的操作：注册、登录、注销')
    if choose1.lower() =='q':
        print('已退出登录')
        break
    elif choose1 == '登录':
        name = input("请输入您的账号名：")
        pwd = input("请输入您的密码：")
        f=open('users.csv',mode='r',encoding='UTF-8')
        res1 = f.readlines()
        list1=[]
        list2=[]
        for list in res1:
            list = list.strip()
            list_split = list.split(',')
            list1.append(list_split[0])
            list2.append(list_split[1])
            if name in list1:
                namenum=list1.index(name)
                if list2[namenum]==pwd:
                    print('登录成功')
                else:
                    print('密码不正确')
            else:
                print('账号不存在，请注册：')
                break
    f.close()








# #注册账号的函数
# def zhuce():
#     f = open('users.csv',mode='a',encoding='UTF-8')
#     while True:
#         name = input("请输入您要创建的账号名：")
#         if name.upper() == 'Q':
#             break
#         pwd = input("请输入您要创建的密码：")
#         email = input("请输入您要创建的邮箱：")
#         infos = f"{name},{pwd},{email}\n"
#         f.write(infos)
#         f.flush()
#         print('恭喜您注册成功！')
#         print(f'您的账号名为：{name}')
#         print(f'您的密码名为：{pwd}')
#         print(f'您的邮箱名为：{email}')
#         break
#     f.close()
#
#
# def denglu():
#     f = open('users.csv', mode='r', encoding='GBK')
#     res1 = f.readlines()
#
#
#
#
#
#
#
# def zhuxiao():
#
#
# if choose1=='注册':
#     zhuce()
# elif choose1=='登录':
#     denglu()
# elif choose1=='注销':
#     zhuxiao()
# else:
#     print('已退出')
#     break
#
#








